<template>
  <div>  
    <van-cell-group>
      <van-field v-model="user.phone" label="账号" placeholder="请输入用户名" />
    </van-cell-group>
    <van-cell-group>
      <van-field v-model="user.nickname" label="昵称" placeholder="请输入用户名" />
    </van-cell-group>
    <van-cell-group>
      <van-field v-model="user.password" label="密码" placeholder="请输入用户名" />
    </van-cell-group>

      <van-button @click="register" type="primary" block>注册</van-button>
  </div>
</template>

<script>
import {reqRegister} from "../../http/http";
import { Toast } from "vant";
export default {
    data(){
      return {
        user:{
          phone:"",
          nickname:"",
          password:""
        }
      }
    },
    methods:{
      // 注册
      register(){
         reqRegister(this.user).then(res=>{
            // console.log(res);
            if(res.data.code === 200){
              Toast(res.data.msg);
              this.$router.push("/login");
            }else{
              Toast(res.data.msg)
            }
          })
      }
    }
}
</script>

<style>

</style>